﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Xml;
using System.Xml.Serialization;

namespace IssueServiceLibrary
{
    [DataContract]
    public class Issue
    {
        public static int nextID = 0;

        [XmlAttribute]
        [DataMember]
        public string IssueId;

        [XmlAttribute]
        [DataMember]
        public string Name;

        [XmlAttribute]
        [DataMember]
        public string Description;

        [XmlAttribute]
        [DataMember]
        public DateTime CreationDate;

        [XmlAttribute]
        [DataMember]
        public DateTime DueDate;
        
        [XmlAttribute]
        [DataMember]
        public User UserAssignedTo;

        [XmlAttribute]
        [DataMember]
        public StatusEnum status;

        [XmlAttribute]
        [DataMember]
        public float HoursWorked;

        [XmlAttribute]
        [DataMember]
        public float HoursLeftToGo;
        
        [DataContract(Name = "Status")]
        public enum StatusEnum
        {
            [EnumMember]
            NotStarted,
            [EnumMember]
            InProgress,
            [EnumMember]
            Completed
        }

        public override bool Equals(object obj)
        {
            Issue other = (Issue)obj;
            if(other.IssueId.Equals(this.IssueId,StringComparison.OrdinalIgnoreCase))
                return true;
            else
                return false;
        }
    }
}
